import { Caller } from "../../../com/gengine/core/call/Caller";
//class CallLater

export class CallLater {
  public static addCallBack(arg1: Function): void {
    if (arg1 in CallLater._closureMap) {
      return;
    }
    CallLater._call.addCall(CallLater.CallType, arg1);
    if (CallLater._isCall == false) {
      setTimeout(CallLater.callBack, 50);
      CallLater._isCall = true;
    }
    return;
  }

  /* internal  */ static callBack(): void {
    CallLater._call.call(CallLater.CallType);
    CallLater._isCall = false;
    CallLater._call.removeCallByType(CallLater.CallType);
    CallLater._closureMap = new Map<any, any> /* flash.utils.Dictionary */();
    return;
  }

  private static /* var */ _call: Caller;

  private static /* var */ _isCall: Boolean = false;

  private static /* var */ CallType: string = "CallLater";

  private static /* var */ _closureMap: Map<
    any,
    any
  > /* flash.utils.Dictionary */;
}

CallLater._call = new Caller();
CallLater._isCall = false;
CallLater.CallType = "CallLater";
CallLater._closureMap = new Map<any, any> /* flash.utils.Dictionary */();
